package com.wst.wst_server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wst.wst_server.entity.Person;
import com.wst.wst_server.mapper.PersonMapper;
import com.wst.wst_server.service.IPersonService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyk
 * @since 2023-03-24
 */
@Service
public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person> implements IPersonService {

    @Autowired
    PersonMapper personMapper;
    @Override
    public IPage<Map<String, Object>> getbypersonandsection(Map<String, Object> map) {
        Page page = new Page(Integer.parseInt(map.get("page").toString()),Integer.parseInt(map.get("count").toString()));
        QueryWrapper queryWrapper = new QueryWrapper();
        Set<String> keys = map.keySet();
        for (String key : keys) {
            if("page".equals(key) || "count".equals(key))
                continue;
            else
                queryWrapper.eq(key,map.get(key));
        }

        return personMapper.getbypersonandsection(page,queryWrapper);
    }

    @Override
    public Map<String, Object> getbypersonsection(Map<String, Object> map) {
        QueryWrapper queryWrapper = new QueryWrapper();
        Set<String> keys = map.keySet();
        for (String key : keys) {
            queryWrapper.eq(key,map.get(key));
        }

        return personMapper.getbypersonsection(queryWrapper);
    }

    @Override
    public IPage<Map<String, Object>> getbypersoncondition(Map<String, Object> map) {
         Page page = new Page(Integer.parseInt(map.get("page").toString()),Integer.parseInt(map.get("count").toString()));
        QueryWrapper queryWrapper = new QueryWrapper();
        Set<String> keys = map.keySet();
        for (String key : keys) {
            if("page".equals(key) || "count".equals(key))
                continue;
            else if(map.get(key).equals(null)){
                System.out.println(map.get(key));
                continue;
            }
            else
                queryWrapper.eq(key,map.get(key));
        }

        return personMapper.getbypersonandsection(page,queryWrapper);
    }

    @Override
    public List<Map<String, Object>> get1(List<Integer> ids) {
        return personMapper.get1(ids);
    }

    @Override
    public List<Map<String, Object>> get2(List<Integer> ids) {
        return personMapper.get2(ids);
    }

    @Override
    public List<Map<String, Object>> get3(List<Integer> ids) {
        return personMapper.get3(ids);
    }

    @Override
    public List<Map<String, Object>> get4(List<Integer> ids) {
        return personMapper.get4(ids);
    }

    @Override
    public List<Map<String, Object>> get5(List<Integer> ids) {
        return personMapper.get5(ids);
    }

    @Override
    public List<Map<String, Object>> get6(List<Integer> ids) {
        return personMapper.get6(ids);
    }

    @Override
    public List<Map<String, Object>> get7(List<Integer> ids) {
        return personMapper.get7(ids);
    }

    @Override
    public List<Map<String, Object>> get8(List<Integer> ids) {
        return personMapper.get8(ids);
    }

    @Override
    public List<Map<String, Object>> get9(List<Integer> ids) {
        return personMapper.get9(ids);
    }

    @Override
    public List<Map<String, Object>> get10(List<Integer> ids) {
        return personMapper.get10(ids);
    }

    @Override
    public List<Map<String, Object>> get11(List<Integer> ids) {
        return personMapper.get11(ids);
    }

    @Override
    public List<Map<String, Object>> get12(List<Integer> ids) {
        return personMapper.get12(ids);
    }
}
